package cn.t.service.device;

import cn.t.constants.CommonConstants;
import cn.t.core.service.ServiceImpl;
import cn.t.model.device.FaultDO;
import cn.t.repository.device.FaultRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 设备报警信息表(日志)(Fault)领域服务
 *
 * @author t
 * @since 2024-05-24 10:19:11
 */
@Slf4j
@Service
@AllArgsConstructor
public class FaultService extends ServiceImpl<FaultDO, FaultRepository> {
    // 查询故障货道
    public List<Long> getFaultCargowayIds(List<Long> deviceIds) {

        FaultDO queryParam = new FaultDO();
        queryParam.setDeviceIds(deviceIds);
        List<FaultDO> faultDOS = this.findByModel(queryParam, CommonConstants.ZERO, Integer.MAX_VALUE, null, null);

        return faultDOS.stream().map(FaultDO::getCargowayId).collect(Collectors.toList());
    }
}
